package tq.com.crop;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.MediaStore;


import java.io.File;

/**
 * Author:    ZhuWenWu
 * Version    V1.0
 * Date:      15/8/18 22:57
 * Description:
 * Modification  History:
 * Date         	Author        		Version        	Description
 * -----------------------------------------------------------------------------------
 * 15/8/18      ZhuWenWu            1.0                    1.0
 * Why & What is modified:
 */
public class CropIntent {
    public static final String ASPECT_X = "aspectX";
    public static final String ASPECT_Y = "aspectY";
    public static final String OUTPUT_X = "outputX";
    public static final String OUTPUT_Y = "outputY";
    public static final String MAX_OUTPUT_X = "maxOutputX";
    public static final String MAX_OUTPUT_Y = "maxOutputY";
    public static final String Rotate = "rotate";

    private Intent mCropIntent = new Intent();

    public void setImagePath(String filepath) {
        setImagePath(Uri.fromFile(new File(filepath)));
    }

    public void setImagePath(Uri uri) {
        mCropIntent.setData(uri);
    }

    public void setOutputPath(String filepath) {
        setOutputPath(Uri.fromFile(new File(filepath)));
    }

    public void setOutputPath(Uri uri) {
        mCropIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    }

    public void setAspect(int x, int y) {
        mCropIntent.putExtra(ASPECT_X, x);
        mCropIntent.putExtra(ASPECT_Y, y);
    }

    public void setOutputSize(int x, int y) {
        mCropIntent.putExtra(OUTPUT_X, x);
        mCropIntent.putExtra(OUTPUT_Y, y);
    }

    public void setMaxOutputSize(int x, int y) {
        mCropIntent.putExtra(MAX_OUTPUT_X, x);
        mCropIntent.putExtra(MAX_OUTPUT_Y, y);
    }

    public void setRotate(boolean r){
        mCropIntent.putExtra(Rotate, r);
    }
    public boolean rotate(){
        return mCropIntent.getBooleanExtra(Rotate, false);
    }
    public Intent getIntent(Context context) {
        mCropIntent.setClass(context, CropImageActivity.class);
        return mCropIntent;
    }
}
